#include <algorithm>
#include <fstream>
#include <iostream>
#include <math.h>

using namespace std;

#define INF (1 << 30)	//INFINIT
#define N_MAX 100

class Punct{
public:
	int x, y;
    
	Punct(){};
	Punct(int x, int y){
		this->x = x;
		this->y = y;
	}
	friend istream &operator >> (istream &in, Punct &a);
	friend ostream &operator << (ostream &out, Punct &a);
};

istream &operator >> (istream &in, Punct &a){
	in >> a.x >> a.y;
    
	return in;
}

ostream &operator << (ostream &out, Punct &a){
	out << "(" << a.x << ", " << a.y << ")";
    
	return out;
}

class Segment{
public:
	Punct a, b;
	double panta;
    
	Segment(){}
	Segment(Punct a, Punct b){
		this->a = a;
		this->b = b;
        
		panta = getPanta();
	}
    
	double getPanta(){
		if(b.x - a.x == 0)
			return INF;
		return (double) (b.y - a.y) / (b.x - a.x);
	}
    
	double getLungime(){
		return sqrtl((b.y - a.y) * (b.y - a.y) + (b.x - a.x) * (b.x - a.x));
	}
};

class Poligon{
public:
	Punct puncte[N_MAX];
	int size;
    
	Poligon(){
		this->size = 0;
	}
	Poligon(Punct a[], int size){
		for(int i = 0; i < min(N_MAX, size); i ++)
			puncte[i] = a[i];
		this->size = size;
	}
    
	void add(Punct a){
		if(size + 1 >= N_MAX)
			return ;
		puncte[size ++] = a;
	}
	friend ostream &operator << (ostream &out, Poligon &a);
};

ostream &operator << (ostream &out, Poligon &a){
	for(int i = 0; i < a.size; i ++)
		out << a.puncte[i] << "\n";
}

//Numere complexe

class complex{
public:
	double real, imag;
	complex(){
		this->real = this->imag = 0;
	}
	complex(double real, double imag){
		this->real = real;
		this->imag = imag;
	}
    
	complex operator * (complex b){
		return complex(real * b.real, imag * b.imag);
	}
    
	double modul(){
		return sqrt(real * real + imag * imag);
	}
	friend istream &operator >> (istream &in, complex &a);
	friend ostream &operator << (ostream &out, complex &a);
};

istream &operator >> (istream &in, complex &a){
	in >> a.real >> a.imag;
    
	return in;
}

ostream &operator << (ostream &out, complex &a){
	out << a.real << " + " << a.imag << "i";
    
	return out;
}


class comp{
public:
	virtual bool cmp(complex a, complex b){
		return false;//degeaba
	}
};

class cresc : public comp{
public:
	bool cmp(complex a, complex b){
		return a.modul() < b.modul();
	}
};

class descr : public comp{
public:
	bool cmp(complex a, complex b){
		return a.modul() > b.modul();
	}
};

class NumereComplexe{
public:
	complex complexe[N_MAX];
	int size;
    
	NumereComplexe(){
		size = 0;
	}
    
	void add(complex a){
		if(size + 1 >= N_MAX)
			return ;
		complexe[size ++] = a;
	}
    
	void sort(comp *a){
		for(int i = 0; i < size; i ++)
			for(int j = i + 1; j < size; j ++)
				if(a->cmp(complexe[i], complexe[j]) == false)
					swap(complexe[i], complexe[j]);
	}
    
	friend istream &operator >> (istream &in, NumereComplexe &a);
	friend ostream &operator << (ostream &out, NumereComplexe &a);
    
};

istream &operator >> (istream &in, NumereComplexe &a){
	cout << "size :\n";	in >> a.size;
	cout << "complexe :\n";
	for(int i = 0; i < a.size; i ++)
    {
        cout<<"=";
		in >> a.complexe[i];
    }
	return in;
}

ostream &operator << (ostream &out, NumereComplexe &a){
	for(int i = 0; i < a.size; i ++)
		out << a.complexe[i] << "\n";//" " << a.complexe[i].modul() << "\n";
    
	return out;
}

int main(){
    
	//Testing
	//***********
	Punct a, b;
	cout << "puncte :\n";	cin >> a >> b;
    
	Segment seg(a, b);
    
	cout << "lungime :\n";	cout << seg.getLungime();
	cout << "\n";
    
	Punct x[] = {Punct(2, 3), Punct(3, 5), Punct(8, 1), Punct(5, 6)};
	Poligon pol(x, 4);
	pol.add(Punct(1, 5));
    
	cout << "poligon :\n";	cout << pol;
	cout << "\n";
    
	NumereComplexe nrC;
	cin >> nrC;
    
	nrC.sort(new cresc);
	cout << "crescator :\n";	cout << nrC;
	cout << "\n";
    
	nrC.sort(new descr);
	cout << "descrescator :\n";	cout << nrC;
	//***********
    
	return 0;
}